require('../css/common/normalize.css')
require('../css/common/reset.css')
require('../css/common/property.css')
require('../css/common/basic.less')
require('../lib/fonts/iconfont.css')
require('../css/motion-course.less') 

//导入axios
const axios = require("axios");

//导入weui
require("weui")
const weui = require("weui.js")

let video=document.querySelector('#video')
let imgurl=document.querySelector('#imgurl')
let desc=document.querySelector('#desc')

document.addEventListener('DOMContentLoaded',function(){
    //点击return回到上一个页面
    document.querySelector('.goReturn').addEventListener('click',function(){
        console.log(12563);
        history.go(-1)
    })

    //获取详情页面
    axios.get('http://139.9.177.51:8099/sports/courseDetail',{
        params:{
            id:sessionStorage.getItem('cid')
        }
    }).then(function(res){
        let data=res.data.data
        console.log(data);
        sessionStorage.setItem('fragments',JSON.stringify(data.fragments))

        //获取视频
       // console.log(data.fragments[0])
        video.src="http://139.9.177.51:8099"+data.fragments[0].videoUrl

        //获取名字
        document.querySelector('#reName').textContent=data.name

        //卡路里
        document.querySelector('.calorie').textContent=data.calorie


        //获取时间
        document.querySelector('#time').textContent=data.time

        //人数
        document.querySelector('#peoplenum').textContent=data.peoplenum

        //头像
        imgurl.src="http://139.9.177.51:8099"+data.imgurl
        
        //课程详情
        desc.textContent=data.desc

        //练习次数
        document.querySelector('#frequency').textContent=data.frequency

        //器材个数
        document.querySelector('#instrument').textContent=data.instrument

    })

})
